<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <title>编辑信息</title>
    <link rel="stylesheet" href="../css/page-health-orderInfo.css" />
    <link rel="stylesheet" href="../plugins/elementui/index.css" />
    <script src="../plugins/jquery/dist/jquery.min.js"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script src="../plugins/datapicker/datePicker.js"></script>
    <script src="../plugins/vue/vue.js"></script>
    <script src="../plugins/vue/axios-0.18.0.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script>
        var id = getUrlParam("id");//根据URL地址栏中的参数名称获取对应的值
    </script>
</head>
<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
<div id="app" class="app">
    <!-- 页面头部 -->
    <div class="top-header">
        <span class="f-left"><i class="icon-back" onclick="history.go(-1)"></i></span>
        <span class="center">传智健康</span>
        <span class="f-right"><i class="icon-more"></i></span>
    </div>
    <!-- 页面内容 -->
    <div class="contentBox">

        <div class="form-info">
            <div class="info-title">
                <span class="name">信息详情</span>
            </div>
            <form class="info-form">
                <!--用户名-->
                <div class="input-row">
                    <label>用户名</label>
                    <input v-model="orderInfo.name" type="text" class="input-clear" placeholder="未设置">
                </div>
                <!--性别-->
                <div class="input-row single-radio">
                    <label class="radio-title">性别</label>
                    <div class="radio-list">
                        <div class="radio">
                            <input v-model="orderInfo.sex" id="item1" type="radio" name="sex" value="1" checked>
                            <label for="item1"></label>
                            <span>男</span>
                        </div>
                        <div class="radio">
                            <input v-model="orderInfo.sex" id="item2" type="radio" name="sex" value="2">
                            <label for="item2"></label>
                            <span>女</span>
                        </div>
                    </div>
                </div>
                <!--手机号-->
                <div class="input-row">
                    <label>手机号</label>
                    <input v-model="orderInfo.phoneNumber" type="text" class="input-clear" readonly>
                </div>
                <!--身份证号码-->
                <div class="input-row">
                    <label>身份证号码</label>
                    <input v-model="orderInfo.idCard" type="text" class="input-clear" placeholder="请输入身份证号码">
                </div>

                <!--出生日期-->
                <div class="birth-class" style="background-color: #fff;">
                    <label
                            style="font-size: 14px;margin: 2% 0 6.7%;padding: 4% 3.7%;color: #555;"
                    >出生日期</label>
                    <el-date-picker
                            v-model="orderInfo.birthday"
                            type="date"
                            placeholder="请选择出生日期"
                            value-format="yyyy-MM-dd"
                    >
                    </el-date-picker>
                </div>

                <!--邮箱-->
                <div class="input-row">
                    <label>邮箱</label>
                    <input v-model="orderInfo.email" type="text" class="input-clear" placeholder="请输入邮箱账号">
                </div>

                <!--注册日期-->
                <div class="date">
                    <label>注册日期</label>
                    <i class="icon-date" class="picktime"></i>
                    <input v-model="orderInfo.regTime" type="text" class="input-clear" readonly>
                    <!--<input :disabled="true" v-model="orderInfo.regTime" type="text" class="picktime" readonly>-->
                </div>

            </form>
            <div class="box-button">
                <button @click="submitOrder()" type="button" class="btn order-btn">修改个人信息</button>
            </div>
        </div>
    </div>
</div>
<script>
    var vue = new Vue({
        el:'#app',
        data:{
            setmeal:{},//套餐信息
            orderInfo:{
                name: '',
                sex: '',
                phoneNumber: '',
                idCard: '',
                birthday: '',
                email: '',
                regTime: '',
            }
        },
        methods:{

            //提交修改
            submitOrder(){
                console.log("this.orderInfo",this.orderInfo)

                //用户名不能为空
                var name = this.orderInfo.name;
                if(name==null||name=="") {
                    this.$message.error("用户名不能为空,请输入您的用户名");
                    return false;
                }

                //身份证校验
                var idCard = this.orderInfo.idCard;
                if(!checkIdCard(idCard)){
                    //身份证号输入不合法
                    this.$message.error("身份证号码输入错误，请您重新输入");
                    return false;
                }

                //邮箱校验
                var email = this.orderInfo.email;
                if(email == null || email == undefined || email == "")
                {
                    this.$message.error("用户的Email不能为空");
                    $("#email").focus();
                    return false;
                }
                //邮箱格式的判断
                if(!email.match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/)) {
                    this.$message.error("输入的email格式错误!");
                    $("#email").focus();
                    return false;
                }

                //发送ajax请求，提交表单数据到后台进行业务处理
                axios.post("/member/editMemberInfo.do",this.orderInfo).then((res) => {
                    if(res.data.flag){
                        //修改成功,跳转到index.html
                        this.$message.success(res.data.message+",三秒后返回首页");

                        setTimeout(function(){

                            window.location.href = "index.html";
                        },3000);
                    }else{
                        //修改失败，提示信息
                        this.$message.error(res.data.message);
                    }
                });
            }
        },

        mounted(){
            //发送ajax请求,查询当前用户信息,用于页面展示
            axios.get("/member/checkIsLogin.do").then((response)=>{
                if(response.data.flag){
                    //查询数据
                    this.orderInfo=response.data.data;
                    // this.$message.success(response.data.message);
                }else{
                    //查询失败
                    this.$message.error(response.data.message);
                    return false;
                }
            })
        }
    });
</script>

<script>
    export default {
        data() {
            return {
                pickerOptions: {
                    disabledDate(time) {
                        return time.getTime() > Date.now();
                    },
                },
                value1: '',
            };
        }
    };
</script>
</body>
</html>